<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 1.逻辑与 && 相当于and
        console.log(3 > 5 && 3 > 2); //false
        console.log(3 < 5 && 3 > 2); //true

        //2.逻辑或 || 相当于or
        console.log(3 > 5 || 3 > 2); //true
        console.log(3 > 5 || 3 < 2); //false

        //3.逻辑not !
        var isOk = !true;
        console.log(isOk); //false

        //3.逻辑与短路运算 如果表达式1结果为真 则返回表达式2
        console.log(123 && 456); //456
        // 如果表达式1为假，则返回表达式1
        console.log(0 && 456); //0

        //4.逻辑或短路运算 如果表达式1结果为真 则返回表达式1
        console.log(123 || 456); //123
        // 如果表达式1为假，则返回表达式2
        console.log(0 || 456); //456
        console.log(1 || 123 || 456); //1

        var num = 0;
        console.log(123 || num++); //num++不会执行
        console.log(num); //0
    </script>
</head>

<body>

</body>

</html>